package academic.emailClient.control.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import academic.emailClient.model.EmailClientModel;
import academic.emailClient.model.entities.Meeting;
import academic.emailClient.view.EmailClientViewInterface;

public class DeleteMeetingActionListener implements ActionListener{
	
	private EmailClientViewInterface view;
	private EmailClientModel model;
	
/**
 * constructor
 * 	
 * @param view
 * @param model
 */
	public DeleteMeetingActionListener(EmailClientViewInterface view, EmailClientModel model) {
		super();
		this.view = view;
		this.model = model;
	}

	/**
	 * Handle Delete Meeting Action event
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		Meeting meeting	= view.getMeetingObject();
		model.cancelMeeting(meeting.getId());
		view.displaySuccessfulMeetingDelete(meeting);
		// Load the Meetings cb
		ArrayList<Meeting> meetings = new ArrayList<Meeting>(model.getMeetings().values());
		view.loadModifyMeetingsCb(meetings);
	}
}

